
import { BaseState, StateMachine } from "../base/fsm";
import EventManager from "../manager/EventManager";
import Unit from "./Unit";


export const SkillEvent = {
    Prepare:'Prepare',
    Spell:'Spell',
    CD:'CD',
}
export  class SkillState extends BaseState<Unit>{
    fsm: Skill = null;
    constructor(fsm:Skill,name:string){
        super();
        this.fsm = fsm;
        this.name = name;
    }
    onEnter() {
    }
    onUpdate() {
    }
    onQuit() {
    }
}
export class PrepareState extends SkillState {}
export class SpellState extends SkillState {}
export class CDState extends SkillState {}
export abstract class Skill extends StateMachine<Unit>{

    unit: Unit = null;
    skillData = null;
    cd: number;
    defaultState: SkillState = null;
    public constructor(skillData) {
        super();
        this.skillData = skillData;
        this.init();
    }
    public abstract init();
    public on (){

    }
    public off(){

    }
    public sendEvent (eventType:string,...arg){
        EventManager.instance.emit(eventType,...arg);
    }
    // public spell() {
    //     this.run(this.states.get('spell'));
    // }
    // public forbid() {
    //     this.run(this.states.get('cd'));
    // }
    public abstract checkCanSpell(): boolean ;
}
